home *** CD-ROM | disk | FTP | other *** search
/ Skunkware 5 / Skunkware 5.iso / man / man.3 / CrtErrHdlr.3 < prev    next >
Text File  |  1995-07-21  |  11KB  |  344 lines

  1. '\"
  2. '\" Copyright (c) 1990 The Regents of the University of California.
  3. '\" All rights reserved.
  4. '\"
  5. '\" Permission is hereby granted, without written agreement and without
  6. '\" license or royalty fees, to use, copy, modify, and distribute this
  7. '\" documentation for any purpose, provided that the above copyright
  8. '\" notice and the following two paragraphs appear in all copies.
  9. '\"
  10. '\" IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY
  11. '\" FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES
  12. '\" ARISING OUT OF THE USE OF THIS DOCUMENTATION, EVEN IF THE UNIVERSITY OF
  13. '\" CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  14. '\"
  15. '\" THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY WARRANTIES,
  16. '\" INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
  17. '\" AND FITNESS FOR A PARTICULAR PURPOSE.  THE SOFTWARE PROVIDED HEREUNDER IS
  18. '\" ON AN "AS IS" BASIS, AND THE UNIVERSITY OF CALIFORNIA HAS NO OBLIGATION TO
  19. '\" PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
  20. '\" 
  21. '\" $Header: /user6/ouster/wish/man/RCS/CrtErrHdlr.3,v 1.6 93/04/01 09:41:13 ouster Exp $ SPRITE (Berkeley)
  22. '\" 
  23. .\" The definitions below are for supplemental macros used in Tcl/Tk
  24. .\" manual entries.
  25. .\"
  26. .\" .HS name section [date [version]]
  27. .\"    Replacement for .TH in other man pages.  See below for valid
  28. .\"    section names.
  29. .\"
  30. .\" .AP type name in/out [indent]
  31. .\"    Start paragraph describing an argument to a library procedure.
  32. .\"    type is type of argument (int, etc.), in/out is either "in", "out",
  33. .\"    or "in/out" to describe whether procedure reads or modifies arg,
  34. .\"    and indent is equivalent to second arg of .IP (shouldn't ever be
  35. .\"    needed;  use .AS below instead)
  36. .\"
  37. .\" .AS [type [name]]
  38. .\"    Give maximum sizes of arguments for setting tab stops.  Type and
  39. .\"    name are examples of largest possible arguments that will be passed
  40. .\"    to .AP later.  If args are omitted, default tab stops are used.
  41. .\"
  42. .\" .BS
  43. .\"    Start box enclosure.  From here until next .BE, everything will be
  44. .\"    enclosed in one large box.
  45. .\"
  46. .\" .BE
  47. .\"    End of box enclosure.
  48. .\"
  49. .\" .VS
  50. .\"    Begin vertical sidebar, for use in marking newly-changed parts
  51. .\"    of man pages.
  52. .\"
  53. .\" .VE
  54. .\"    End of vertical sidebar.
  55. .\"
  56. .\" .DS
  57. .\"    Begin an indented unfilled display.
  58. .\"
  59. .\" .DE
  60. .\"    End of indented unfilled display.
  61. .\"
  62. '\"    # Heading for Tcl/Tk man pages
  63. .de HS
  64. .ds ^3 \\0
  65. .if !"\\$3"" .ds ^3 \\$3
  66. .if '\\$2'cmds'       .TH \\$1 1 \\*(^3 \\$4
  67. .if '\\$2'lib'        .TH \\$1 3 \\*(^3 \\$4
  68. .if '\\$2'tcl'        .TH \\$1 n \\*(^3 Tcl "Tcl Built-In Commands"
  69. .if '\\$2'tk'         .TH \\$1 n \\*(^3 Tk "Tk Commands"
  70. .if '\\$2'tclc'        .TH \\$1 3 \\*(^3 Tcl "Tcl Library Procedures"
  71. .if '\\$2'tkc'         .TH \\$1 3 \\*(^3 Tk "Tk Library Procedures"
  72. .if '\\$2'tclcmds'         .TH \\$1 1 \\*(^3 Tk "Tcl Applications"
  73. .if '\\$2'tkcmds'         .TH \\$1 1 \\*(^3 Tk "Tk Applications"
  74. .if t .wh -1.3i ^B
  75. .nr ^l \\n(.l
  76. .ad b
  77. ..
  78. '\"    # Start an argument description
  79. .de AP
  80. .ie !"\\$4"" .TP \\$4
  81. .el \{\
  82. .   ie !"\\$2"" .TP \\n()Cu
  83. .   el          .TP 15
  84. .\}
  85. .ie !"\\$3"" \{\
  86. .ta \\n()Au \\n()Bu
  87. \&\\$1    \\fI\\$2\\fP    (\\$3)
  88. .\".b
  89. .\}
  90. .el \{\
  91. .br
  92. .ie !"\\$2"" \{\
  93. \&\\$1    \\fI\\$2\\fP
  94. .\}
  95. .el \{\
  96. \&\\fI\\$1\\fP
  97. .\}
  98. .\}
  99. ..
  100. '\"    # define tabbing values for .AP
  101. .de AS
  102. .nr )A 10n
  103. .if !"\\$1"" .nr )A \\w'\\$1'u+3n
  104. .nr )B \\n()Au+15n
  105. .\"
  106. .if !"\\$2"" .nr )B \\w'\\$2'u+\\n()Au+3n
  107. .nr )C \\n()Bu+\\w'(in/out)'u+2n
  108. ..
  109. '\"    # BS - start boxed text
  110. '\"    # ^y = starting y location
  111. '\"    # ^b = 1
  112. .de BS
  113. .br
  114. .mk ^y
  115. .nr ^b 1u
  116. .if n .nf
  117. .if n .ti 0
  118. .if n \l'\\n(.lu\(ul'
  119. .if n .fi
  120. ..
  121. '\"    # BE - end boxed text (draw box now)
  122. .de BE
  123. .nf
  124. .ti 0
  125. .mk ^t
  126. .ie n \l'\\n(^lu\(ul'
  127. .el \{\
  128. .\"    Draw four-sided box normally, but don't draw top of
  129. .\"    box if the box started on an earlier page.
  130. .ie !\\n(^b-1 \{\
  131. \h'-1.5n'\L'|\\n(^yu-1v'\l'\\n(^lu+3n\(ul'\L'\\n(^tu+1v-\\n(^yu'\l'|0u-1.5n\(ul'
  132. .\}
  133. .el \}\
  134. \h'-1.5n'\L'|\\n(^yu-1v'\h'\\n(^lu+3n'\L'\\n(^tu+1v-\\n(^yu'\l'|0u-1.5n\(ul'
  135. .\}
  136. .\}
  137. .fi
  138. .br
  139. .nr ^b 0
  140. ..
  141. '\"    # VS - start vertical sidebar
  142. '\"    # ^Y = starting y location
  143. '\"    # ^v = 1 (for troff;  for nroff this doesn't matter)
  144. .de VS
  145. .mk ^Y
  146. .ie n 'mc \s12\(br\s0
  147. .el .nr ^v 1u
  148. ..
  149. '\"    # VE - end of vertical sidebar
  150. .de VE
  151. .ie n 'mc
  152. .el \{\
  153. .ev 2
  154. .nf
  155. .ti 0
  156. .mk ^t
  157. \h'|\\n(^lu+3n'\L'|\\n(^Yu-1v\(bv'\v'\\n(^tu+1v-\\n(^Yu'\h'-|\\n(^lu+3n'
  158. .sp -1
  159. .fi
  160. .ev
  161. .\}
  162. .nr ^v 0
  163. ..
  164. '\"    # Special macro to handle page bottom:  finish off current
  165. '\"    # box/sidebar if in box/sidebar mode, then invoked standard
  166. '\"    # page bottom macro.
  167. .de ^B
  168. .ev 2
  169. 'ti 0
  170. 'nf
  171. .mk ^t
  172. .if \\n(^b \{\
  173. .\"    Draw three-sided box if this is the box's first page,
  174. .\"    draw two sides but no top otherwise.
  175. .ie !\\n(^b-1 \h'-1.5n'\L'|\\n(^yu-1v'\l'\\n(^lu+3n\(ul'\L'\\n(^tu+1v-\\n(^yu'\h'|0u'\c
  176. .el \h'-1.5n'\L'|\\n(^yu-1v'\h'\\n(^lu+3n'\L'\\n(^tu+1v-\\n(^yu'\h'|0u'\c
  177. .\}
  178. .if \\n(^v \{\
  179. .nr ^x \\n(^tu+1v-\\n(^Yu
  180. \kx\h'-\\nxu'\h'|\\n(^lu+3n'\ky\L'-\\n(^xu'\v'\\n(^xu'\h'|0u'\c
  181. .\}
  182. .bp
  183. 'fi
  184. .ev
  185. .if \\n(^b \{\
  186. .mk ^y
  187. .nr ^b 2
  188. .\}
  189. .if \\n(^v \{\
  190. .mk ^Y
  191. .\}
  192. ..
  193. '\"    # DS - begin display
  194. .de DS
  195. .RS
  196. .nf
  197. .sp
  198. ..
  199. '\"    # DE - end display
  200. .de DE
  201. .fi
  202. .RE
  203. .sp .5
  204. ..
  205. .HS Tk_CreateErrorHandler tkc
  206. .BS
  207. .SH NAME
  208. Tk_CreateErrorHandler, Tk_DeleteErrorHandler \- handle X protocol errors
  209. .SH SYNOPSIS
  210. .nf
  211. \fB#include <tk.h>\fR
  212. .sp
  213. Tk_ErrorHandler
  214. \fBTk_CreateErrorHandler\fR(\fIdisplay, error, request, minor, proc, clientData\fR)
  215. .sp
  216. \fBTk_DeleteErrorHandler\fR(\fIhandler\fR)
  217. .SH ARGUMENTS
  218. .AS "Tk_ErrorHandler" clientData
  219. .AP Display *display in
  220. Display whose errors are to be handled.
  221. .AP int error in
  222. Match only error events with this value in the \fIerror_code\fR
  223. field.  If -1, then match any \fIerror_code\fR value.
  224. .AP int request in
  225. Match only error events with this value in the \fIrequest_code\fR
  226. field.  If -1, then match any \fIrequest_code\fR value.
  227. .AP int minor in
  228. Match only error events with this value in the \fIminor_code\fR
  229. field.  If -1, then match any \fIminor_code\fR value.
  230. .AP Tk_ErrorProc *proc in
  231. Procedure to invoke whenever an error event is received for
  232. \fIdisplay\fR and matches \fIerror\fR, \fIrequest\fR, and \fIminor\fR.
  233. NULL means ignore any matching errors.
  234. .AP ClientData clientData in
  235. Arbitrary one-word value to pass to \fIproc\fR.
  236. .AP Tk_ErrorHandler handler in
  237. Token for error handler to delete (return value from a previous
  238. call to \fBTk_CreateErrorHandler\fR).
  239. .BE
  240.  
  241. .SH DESCRIPTION
  242. .PP
  243. \fBTk_CreateErrorHandler\fR arranges for a particular procedure
  244. (\fIproc\fR) to be called whenever certain protocol errors occur on a
  245. particular display (\fIdisplay\fR).  Protocol errors occur when
  246. the X protocol is used incorrectly, such as attempting to map a window
  247. that doesn't exist.  See the Xlib documentation for \fBXSetErrorHandler\fR
  248. for more information on the kinds of errors that can occur.
  249. For \fIproc\fR to be invoked
  250. to handle a particular error, five things must occur:
  251. .IP [1]
  252. The error must pertain to \fIdisplay\fR.
  253. .IP [2]
  254. Either the \fIerror\fR argument to \fBTk_CreateErrorHandler\fR
  255. must have been -1, or the \fIerror\fR argument must match
  256. the \fIerror_code\fR field from the error event.
  257. .IP [3]
  258. Either the \fIrequest\fR argument to \fBTk_CreateErrorHandler\fR
  259. must have been -1, or the \fIrequest\fR argument must match
  260. the \fIrequest_code\fR field from the error event.
  261. .IP [4]
  262. Either the \fIminor\fR argument to \fBTk_CreateErrorHandler\fR
  263. must have been -1, or the \fIminor\fR argument must match
  264. the \fIminor_code\fR field from the error event.
  265. .IP [5]
  266. The protocol request to which the error pertains must have been
  267. made when the handler was active (see below for more information).
  268. .PP
  269. \fIProc\fP should have arguments and result that match the
  270. following type:
  271. .nf
  272. .RS
  273. typedef int Tk_ErrorProc(
  274. .RS
  275. ClientData \fIclientData\fR,
  276. XErrorEvent *\fIerrEventPtr\fR);
  277. .RE
  278. .RE
  279. .fi
  280. The \fIclientData\fP parameter to \fIproc\fR is a copy of the \fIclientData\fP
  281. argument given to \fBTcl_CreateErrorHandler\fR when the callback
  282. was created.  Typically, \fIclientData\fR points to a data
  283. structure containing application-specific information that is
  284. needed to deal with the error.  \fIErrEventPtr\fR is
  285. a pointer to the X error event.
  286. The procedure \fIproc\fR should return an integer value.  If it
  287. returns 0 it means that \fIproc\fR handled the error completely and there
  288. is no need to take any other action for the error.  If it returns
  289. non-zero it means \fIproc\fR was unable to handle the error.
  290. .PP
  291. If a value of NULL is specified for \fIproc\fR, all matching errors
  292. will be ignored:  this will produce the same result as if a procedure
  293. had been specified that always returns 0.
  294. .PP
  295. If more than more than one handler matches a particular error, then
  296. they are invoked in turn.  The handlers will be invoked in reverse
  297. order of creation:  most recently declared handler first.
  298. If any handler returns 0, then subsequent (older) handlers will
  299. not be invoked.  If no handler returns 0, then Tk invokes X'es
  300. default error handler, which prints an error message and aborts the
  301. program.  If you wish to have a default handler that deals with errors
  302. that no other handler can deal with, then declare it first.
  303. .PP
  304. The X documentation states that ``the error handler should not call
  305. any functions (directly or indirectly) on the display that will
  306. generate protocol requests or that will look for input events.''
  307. This restriction applies to handlers declared by \fBTk_CreateErrorHandler\fR;
  308. disobey it at your own risk.
  309. .PP
  310. \fBTk_DeleteErrorHandler\fR may be called to delete a
  311. previously-created error handler.  The \fIhandler\fR argument
  312. identifies the error handler, and should be a value returned by
  313. a previous call to \fBTk_CreateEventHandler\fR.
  314. .PP
  315. A particular error handler applies to errors resulting
  316. from protocol requests generated between
  317. the call to \fBTk_CreateErrorHandler\fR and the call to
  318. \fBTk_DeleteErrorHandler\fR.  However, the actual callback
  319. to \fIproc\fR may not occur until after the \fBTk_DeleteErrorHandler\fR
  320. call, due to buffering in the client and server.
  321. If an error event pertains to
  322. a protocol request made just before calling \fBTk_DeleteErrorHandler\fR,
  323. then the error event may not have been processed
  324. before the \fBTk_DeleteErrorHandler\fR
  325. call.  When this situation arises, Tk will save information about
  326. the handler and
  327. invoke the handler's \fIproc\fR later when the error event
  328. finally arrives.
  329. If an application wishes to delete an error handler and know
  330. for certain that all relevant errors have been processed,
  331. it should first call \fBTk_DeleteErrorHandler\fR and then
  332. call \fBXSync\fR;  this will flush out any buffered requests and errors,
  333. but will result in a performance penalty because
  334. it requires communication to and from the X server.  After the
  335. \fBXSync\fR call Tk is guaranteed not to call any error
  336. handlers deleted before the \fBXSync\fR call.
  337. .PP
  338. For the Tk error handling mechanism to work properly, it is essential
  339. that application code never calls \fBXSetErrorHandler\fR directly;
  340. applications should use only \fBTk_CreateErrorHandler\fR.
  341.  
  342. .SH KEYWORDS
  343. callback, error, event, handler
  344.